package com.ashton;

import java.awt.Point;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Pixel {
	Point p;
	int r;//red value
	int g;//green value
	int b;//blue value
	int hds;//horizontal diff sum, sum of red green blue difference
	//between right pixel and left pixel
	int vds;//verticale diff sum, sum of rgb diff for top and bottom pixels
	int ulds;//upper left difference sum
	int urds;//upper right difference sum
	
	public Pixel(int width, int height, int rgbVal){
		p=new Point(width, height);
		set_pixel_colors(rgbVal);
		hds=0;
		vds=0;
		ulds=0;
		urds=0;
	}
	
	int compare(Pixel p_1){
		int r_d=r-p_1.r;
		int g_d=g-p_1.g;
		int b_d=b-p_1.b;
		return Math.abs(r_d+g_d+b_d);
		
	}
	
	Integer get_largest_diff_sum(){
		List<Integer> i= new ArrayList<Integer>();
		i.add(hds);
		i.add(vds);
		i.add(ulds);
		i.add(urds);
		Collections.sort(i);
		return i.get(3);
		
	}
	
	void set_pixel_colors(int rgb){
			r = (rgb>>16)&0x0ff;//red
			g =(rgb>>8) &0x0ff;//green
			b = (rgb)    &0x0ff;//blue
	}
	
	void print_pixel_info(){
		System.out.printf("Point (%d, %d), r %d g %d b %d hds %d vds %d %n", p.x, p.y, r, g, b, hds, vds);
	}

}
